In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
A tournament is a directed graph in which:
Let's take the set of vertices and the permutation : , , , . There are only four tournaments for which this permutation is an automorphism:
Write a program which:
In the first line of the standard input there is one integer , , which is the number of vertices. In the following lines there is a description of a permutation . We assume that vertices are numbered from 1 to . In line there is a value of the permutation for the vertex (i.e. the value ).
In the first and only line of the standard output there should be one integer equal to the remainder of dividing (the number of different -vertex tournaments for which is an automorphism) by .
For the input data:
4 2 4 3 1
the correct result is:
4
Task author: Grzegorz Jakacki.